//
//  allAddressVC.m
//  LoveTrail
//
//  Created by giantumbrella on 15/6/11.
//  Copyright (c) 2015年 赵娟. All rights reserved.
//
/**
 当点击到某一行的时候 会将相应的数据传递到上一个页面
 
 里面的数据是动态增加的 不是一个死数据
 */
#import "allAddressVC.h"
#import "CommonMacro.h"
#import "AministrationAddressVC.h"
#import "ChoseDefaultAddressView.h"
@interface allAddressVC ()

@end

@implementation allAddressVC

- (void)viewDidLoad {
    [super viewDidLoad];
   self.title = @"选择默认收货地址";
    self.view.backgroundColor = [UIColor whiteColor];
    
    //右侧按钮
    UIBarButtonItem *rightButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"管理" style:UIBarButtonItemStylePlain target:self action:@selector(administrationAddress)];
    self.navigationItem.rightBarButtonItem = rightButtonItem;
    self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
    
    [self createSubViews];
}

#pragma mark 创建tableView
- (void)createSubViews
{
    self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)];
    [self.view addSubview:self.tableView];
    self.tableView.dataSource = self;
    self.tableView.delegate = self;
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    
}

#pragma mark 数据源
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 3;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
     static NSString *ID = @"DefaultCell";
    ChoseDefaultAddressView *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if (cell==nil) {
        cell = [[ChoseDefaultAddressView alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:ID];
    }
   
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 160;
}

#pragma mark 管理地址
- (void)administrationAddress
{
    AministrationAddressVC *aminisAdd = [[AministrationAddressVC alloc] init];
    UINavigationController *aminisAddNav = [[UINavigationController alloc]initWithRootViewController:aminisAdd];
    [self presentViewController:aminisAddNav animated:YES completion:nil];

}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

@end
